package com.baosight.sczx.zm.ce.service;


import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.ee.dm.utils.EEDMUtils;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.iplat4j.ep.util.MethodParamConstants;
import com.baosight.sczx.common.zm.cInterface.cs.InitialData;
import com.baosight.sczx.zm.ce.domain.ZMCEA0;
import com.baosight.sczx.zm.ce.domain.ZMCEA1;
import com.baosight.sczx.zm.ce.domain.ZMCEA2;
import com.baosight.sczx.zm.ce.domain.ZMCEA3;
import com.baosight.sczx.zm.ce.domain.ZMCEA4;
import com.baosight.sczx.zm.ce.domain.ZMCEA5;
import com.baosight.sczx.zm.ce.domain.ZMCEA6;
import com.baosight.sczx.zm.ce.domain.ZMCEA7;
import com.baosight.sczx.zm.ce.domain.ZMCEA8;


/**
 * <p>Title: ServiceZMCE53.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 王琪
 * @version 1.0
 * <pre>Histroy:
 *          2011-4-20 下午03:48:30 王琪  Create
 *</pre>
 */
public class ServiceZMCEA0 extends ServiceEPBase {

	/**
	 * 初始化，查询树目录节点
	 * <p>Function: initLoad</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCEA0</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-21 上午 10:21:14 王琪
	 * </p>
	 *
	 */
	public EiInfo initLoad(EiInfo inInfo ){

		EiInfo outInfo = new EiInfo();
		
		outInfo.addBlock(EEDMUtils.generateBlock("mine", new ZMCEA0(), "ZMCEA0.query"));
		outInfo.addBlock(EEDMUtils.generateBlock("system", new ZMCEA1(), "ZMCEA1.query"));
		outInfo.addBlock(EEDMUtils.generateBlock("unit", new ZMCEA2(), "ZMCEA2.query"));
		
		return outInfo;		
	}	
	
	/**
	 * 查询设备运行数据
	 * <p>Function: query</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCEA0</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-21 下午 01:30:24 王琪
	 * </p>
	 *
	 */	
	public EiInfo query(EiInfo inInfo){
		
		EiInfo outInfo = new EiInfo();
		
		inInfo.setMethodParam(MethodParamConstants.sqlName,"ZMCEA2.query");
	    inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA2());		
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "equipment");	
		outInfo.addBlock(super.query(inInfo, true).getBlock("equipment"));
		
		inInfo.setMethodParam(MethodParamConstants.sqlName,"ZMCEA3.query");
	    inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA3());
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "workLoad");
		outInfo.addBlock(super.query(inInfo, true).getBlock("workLoad"));
		
		inInfo.setMethodParam(MethodParamConstants.sqlName, "ZMCEA4.query");
		inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA4());
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "run");
		outInfo.addBlock(super.query(inInfo, true).getBlock("run"));
		
		inInfo.setMethodParam(MethodParamConstants.sqlName, "ZMCEA5.queryDownTime");
		inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA5());
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "down");
		outInfo.addBlock(super.query(inInfo, true).getBlock("down"));		
		
		inInfo.setMethodParam(MethodParamConstants.sqlName, "ZMCEA6.queryFault");
		inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA6());
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "fault");
		outInfo.addBlock(super.query(inInfo, true).getBlock("fault"));		
		
		return outInfo;
	}

	/**
	 * 查询设备变量及寿命分析数据
	 * <p>Function: queryDeviceItems</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCEA0</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-25 下午 01:30:24 王琪
	 * </p>
	 *
	 */	
	public EiInfo queryDeviceItems(EiInfo inInfo){
		
		inInfo.setMethodParam(MethodParamConstants.sqlName,"ZMCEA7.queryItems");
	    inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA7());		
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "item");	
		EiInfo outInfo = super.query(inInfo, true);
		
		inInfo.setMethodParam(MethodParamConstants.sqlName, "ZMCEA4.query");
		inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA4());
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "run");
		outInfo.addBlock(super.query(inInfo, true).getBlock("run"));
		
		outInfo.addBlock(InitialData.getInstance().getEiBlockByNo("cmes.cs.units"));//计量单位
		return outInfo;
		
	}
	
	/**
	 * 查询设备变量运行数据
	 * <p>Function: queryItemsInfo</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCEA0</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-26 下午 01:30:24 王琪
	 * </p>
	 *
	 */	
	public EiInfo queryItemsInfo(EiInfo inInfo){
		
		inInfo.setMethodParam(MethodParamConstants.sqlName,"ZMCEA8.queryMax");
	    inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA8());		
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"checkedBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "max");
		
		EiInfo	outInfo = super.query(inInfo, true);

		inInfo.setMethodParam(MethodParamConstants.sqlName,"ZMCEA8.queryMin");
	    inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA8());
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"checkedBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "min");

		outInfo.addBlock(super.query(inInfo, true).getBlock("min"));
		
		return outInfo;	
	}
	
	/**
	 * 查询效率分析相关数据
	 * <p>Function: queryEffectInfo</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCEA0</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-5-3 上午 09:12:30 王琪
	 * </p>
	 *
	 */	
	public EiInfo queryEffectInfo(EiInfo inInfo){

		inInfo.setMethodParam(MethodParamConstants.sqlName,"ZMCEA2.query");
	    inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA2());		
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "equipment");	
		EiInfo outInfo = super.query(inInfo, true);		

		inInfo.setMethodParam(MethodParamConstants.sqlName, "ZMCEA4.query");
		inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA4());
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "run");
		outInfo.addBlock(super.query(inInfo, true).getBlock("run"));		
		
		inInfo.setMethodParam(MethodParamConstants.sqlName, "ZMCEA6.queryFault");
		inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA6());
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "fault");
		outInfo.addBlock(super.query(inInfo, true).getBlock("fault"));					
		
		return outInfo;
	}
	
	/**
	 * 查询OEE分析相关数据
	 * <p>Function: queryOEEInfo</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCEA0</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-5-5 下午 16:27:30 王琪
	 * </p>
	 *
	 */	
	public EiInfo queryOEEInfo(EiInfo inInfo){

		inInfo.setMethodParam(MethodParamConstants.sqlName,"ZMCEA2.query");
	    inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA2());		
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "equipment");	
		EiInfo outInfo = super.query(inInfo, true);		
		//EiInfo outInfo =  super.query(inInfo, "ZMCE12.query", new ZMCE12(), 
				//false, null, "queryBlock", "result", "equipment" );    //自动分页使用

		inInfo.setMethodParam(MethodParamConstants.sqlName, "ZMCEA5.queryDownTime");
		inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA5());
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "time");
		outInfo.addBlock(super.query(inInfo, true).getBlock("time"));		
		
		inInfo.setMethodParam(MethodParamConstants.sqlName, "ZMCEA3.query");
		inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCEA3());
		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "load");
		outInfo.addBlock(super.query(inInfo, true).getBlock("load"));					
		
		return outInfo;
	}
		
	
	
	
}
